FROM ubuntu:22.04

LABEL maintainer="Zheng Qijun <zhengqijun0121@qq.com>"

# amd64 / arm64
ARG PLATFORM=amd64
ARG AMD64_MIRROR=https://mirrors.tuna.tsinghua.edu.cn
ARG ARM64_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports
ARG DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y --no-install-recommends ca-certificates && \
    if [ "$PLATFORM" == "amd64" ]; then \
        sed -i "s/http://security.ubuntu.com\|http://archive.ubuntu.com/${AMD64_MIRROR}/g" /etc/apt/sources.list \
    elif [ "$PLATFORM" == "arm64" ]; then \
        sed -i "s/http://security.ubuntu.com/ubuntu\|http://ports.ubuntu.com/${ARM64_MIRROR}/g" /etc/apt/sources.list \
    else \
        exit 1 \
    fi && \
    apt update && apt install -y --no-install-recommends tzdata python3 python3-pip vim neovim build-essential \
        curl wget git tig make cmake fontconfig libfontconfig1-dev pkg-config tmux ranger neofetch universal-ctags \
        htop ripgrep tree zip unzip silversearcher-ag xclip && \
    rm -rf /var/lib/apt/lists/* && \
    echo 'root:111111' | chpasswd && \
    mkdir ~/.vnc && echo '111111' | vncpasswd -f > ~/.vnc/passwd && \
    echo 'session=dwm' > ~/.vnc/config && \
    mkdir -p /usr/share/xsessions && \
    echo -e '[Desktop Entry]\n' \
            'Encoding=UTF-8\n' \
            'Name=Dwm\n' \
            'Comment=Dynamic window manager\n' \
            'Exec=dwm\n' \
            'Icon=dwm\n' \
            'Type=XSession' > /usr/share/xsessions/dwm.desktop && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    git config --global user.name 'zhengqijun' && \
    git config --global user.email 'zhengqijun0121@qq.com' && \
    git clone https://gitee.com/zhengqijun/fonts && \
    git clone https://gitee.com/zhengqijun/dwm && \
    git clone https://gitee.com/zhengqijun/slstatus && \
    mkdir ~/.local/fonts && cp -rf ~/fonts/fonts ~/.local/share/ && cd ~/.local/share/fonts && fc-cache -fv && \
    cd ~/dwm && make clean install && \
    cd ~/slstatus && make clean install

ENV TERM xterm-256color
ENV SHELL /bin/bash
ENV HOME /root
ENV USER root
ENV USERNAME root

WORKDIR $HOME

# ENTRYPOINT ["/bin/bash"]

EXPOSE 5921

CMD ["/usr/sbin/vncserver", ":21"]

# EOF

